home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
System Booster
/
System Booster.iso
/
Archives
/
Timing
/
EZCron.lha
/
EZCron
< prev
next >
Wrap
Text File
|
1996-01-17
|
10KB
|
303 lines
/* EZCron by Jim Hines v1.6 ©1995-1996 All Rights Reserved
** 10-23-95 Added requester to verify making a NEW cron.config file. See newrtn:
** 10-25-95 Fixed Bug in the above and added renaming of the old config file. See newrtn:
** renamed from ACron to EZCron. GUI started on this date too.
** 11-30-95 added the text string reminder support and the sfx functions
** 12-05-95 Fixed case sensitivity problem with weekly, monthly & Daily routines
** 12-13-95 Added Speech Function
** 01-04-96 Added Weekdays, Weekend and Quarterly support functions
** 01-05-96 Fixed a bug in the Weekdays routine.
** 01-11-96 Cleaned up the code a bit
** 01-17-95 Added a new routine. ie every_3_wed
*/
/* call trace(all) */
/* ======== Envirorment Varables == */
clock = time('N')
clock2 = LEFT(clock,5)
date = Date(USA)
date2 = Date(S) /* -> 19920804 */
date3 = Date(W, date2, 'S') /* -> Friday */
sec = right(clock, 2) /* Get Seconds */
sec2 = 60 - sec /* 61 (seconds) minus sec) */
delayvar = sec2 * 50 /* sec2 x 50 ticks or 1 second sets the delay time */
LT = delayvar / 50
LTime = 60 - LT
csi='9b'x
Ital=csi'3m'
bold=csi'1m'
norm=csi'0m'
black=csi'31m'
white=csi'32m'
blue=csi'33m'
LF = '0a'x
/* ========END VARABLES == */
arg command lg .
if ~show('L','rexxsupport.library') then
call addlib('rexxsupport.library',0,-30)
if ~show('L','rexxreqtools.library') then
call addlib("rexxreqtools.library", 0, -30, 0)
/* ======== THIS IS THE INPUT PARSING / USAGE SECTION WITH A SUB-ROUTINE== */
select
when command = 'START' then call startrtn()
when command = "STOP" then call stoprtn()
when command = "QUIT" then call stoprtn()
otherwise
say ''
say bold'ERROR,'norm 'Unknown option'blue command norm
call nulinp()
end
stoprtn:
if command = "STOP" then do
if showlist('P', 'ACRON_REXX') then do
say ital 'Exiting ACron: Please Wait. Program will exit in' LT 'seconds!' norm
address 'ACRON_REXX' STOP
exit
end
end
else
say bold ital 'ACron is not running.' norm
exit
end
/* =======LOOP== */
startrtn:
if ~exists('s:cron.config') then do
call rtezrequest('s:cron.config does NOT exist', "Okay", , "rt_reqpos = reqpos_centerscr")
exit
end
RC = showlist('P', 'ACRON_REXX')
if RC = 1 then do
say bold ital white 'ACron is Already Active' norm
exit
end
openport('ACRON_REXX')
SIGNAL on HALT
/* =======PARSE CONFIG FILE SECTION == */
do forever
config = 's:cron.config' /* Name of file for reading events from */
event. = 0
if ~open(cronfile, config,'READ') then do
exit 20
end
errors = 0
do until eof(cronfile)
/* Grab the line, parse the event and ignore the comments */
linein = readln(cronfile)
parse var linein line '#'
next = event.0 + 1
parse var line event.next.command event.next.pargs1 event.next.pargs2,
event.next.pargs3 event.next.pargs4 event.next.time event.next.date,
event.next.sfx event.next.txt
event.next.date = translate(event.next.date, 'abcdefghijklmnopqrstuvwxyz',,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
/* THE ABOVE TRANSLATES THE DATE TO LOWERCASE IF NOT NUMERIC */
event.next.time = translate(event.next.time, 'abcdefghijklmnopqrstuvwxyz',,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
/* THE ABOVE TRANSLATES THE TIME TO LOWERCASE IF NOT NUMERIC */
select
when event.next.command = "" then iterate
when event.next.command = "" then do
say "Not enough fields in:" linein
errors = 1
iterate
end
otherwise event.0 = next
end
end /* end of the do until eof loop */
call close(cronfile)
/* ======== END OF PARSE SECTION == */
sec = right(clock, 2) /* Get Seconds */
sec2 = 60 - sec /* 60 (seconds) minus sec) */
delayvar = sec2 * 50 /* sec2 x 50 ticks or 1 second sets the delay time */
LT = delayvar / 50
LTime = 60 - LT
/* ======== AREXX PORT STUFF == */
pkt = getpkt('ACRON_REXX')
if pkt ~= '0000 0000'x then call aport(pkt)
call delay(delayvar) /* 3000 would be equal to 1 minute */
do i = 1 to event.0
clock = time('N')
clock2 = LEFT(clock,5)
date = Date(USA) /* 08/04/92 */
date2 = Date(S) /* 19920804 */
date3 = Date(W, date2, 'S') /* Friday */
/* ======= Arguments Routine == */
if event.i.pargs1 = '-' then event.i.pargs1 = ''
if event.i.pargs2 = '-' then event.i.pargs2 = ''
if event.i.pargs3 = '-' then event.i.pargs3 = ''
if event.i.pargs4 = '-' then event.i.pargs4 = ''
/* ======= Misc Routines == */
if event.i.sfx = '-' then event.i.sfx = ''
if event.i.txt = '-' then event.i.txt = ''
/* ======= Every Minute Routine == */
if event.i.time = 'minute' then event.i.time = clock2
/* ======= Quarterly Routine Should Go Here == */
parse var clock2 hrs ':' min
if min = 00 & event.i.time = 'quarterly' then event.i.time = clock2
if min = 15 & event.i.time = 'quarterly' then event.i.time = clock2
if min = 30 & event.i.time = 'quarterly' then event.i.time = clock2
if min = 45 & event.i.time = 'quarterly' then event.i.time = clock2
/* ======= Every Hour Routine == */
if min = 00 & event.i.time = 'hourly' then event.i.time = clock2
/* ======= Daily Routine == */
if event.i.date = 'daily' then event.i.date = date
/* ======= Weekly Routine == */
if event.i.date = 'sunday' & date3 = 'Sunday' then event.i.date = date
if event.i.date = 'monday' & date3 = 'Monday' then event.i.date = date
if event.i.date = 'tuesday' & date3 = 'Tuesday' then event.i.date = date
if event.i.date = 'wednesday' & date3 = 'Wednesday' then event.i.date = date
if event.i.date = 'thursday' & date3 = 'Thursday' then event.i.date = date
if event.i.date = 'friday' & date3 = 'Friday' then event.i.date = date
if event.i.date = 'saturday' & date3 = 'Saturday' then event.i.date = date
/* ======= Weekdays Routine == The 'ol Mon-Fri routine */
if event.i.date = 'weekdays' & date3 ~= 'Sunday' & date3 ~= 'Saturday'
then event.i.date = date
/* ======= Weekend Routine == The ol' Sat & Sun routine */
if event.i.date = 'weekend' & date3 = 'Saturday' then event.i.date = date
if event.i.date = 'weekend' & date3 = 'Sunday' then event.i.date = date
/* ======= Monthly Routine == */
month.event = event.i.date
parse var month.event mth '-' day2
if mth = 'monthly' then do
parse var date month '/' day '/' year
if day2 = day & event.i.time = clock2 then event.i.date = date
end
/* ======= # 4th Fri, 2nd Tue, etc routine == */
parse var event.i.date var1 '_' num '_' dow /* every 2 wed */
if var1 = 'every' then do
del3 = date(n) /* 20 Apr 88 */
parse var del3 del1 cm del2
drop del1 del2 /* dont even need them */
if cm = 'Jan' then cm = 31;if cm = 'Feb' then cm = 29
if cm = 'Mar' then cm = 31;if cm = 'Apr' then cm = 30
if cm = 'May' then cm = 31;if cm = 'Jun' then cm = 30
if cm = 'Jul' then cm = 31;if cm = 'Aug' then cm = 31
if cm = 'Sep' then cm = 30;if cm = 'Oct' then cm = 31
if cm = 'Nov' then cm = 30;if cm = 'Dec' then cm = 31
countvar = 0
do z = 1 to cm
currdate = date(s) /* 19951221 year month day */
yearmonth = left(currdate, 6) /* 199512 year month */
if z < 10 then do
zdate = yearmonth'0'z /* 19951201 */
newz = '0'z
end
else do
zdate = yearmonth''z /* 19951231 */
newz = z
end
myday = Date(W, zdate, 'S') /* Friday */
myday = left(myday, 3) /* Fri */
myday = translate(myday, 'abcdefghijklmnopqrstuvwxyz',,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ') /* fri */
if myday = dow then countvar = countvar + 1
if myday = dow & countvar = num then do
year = left(zdate, 4) /* 1995 */
year2 = right(year, 2) /* 95 */
month = right(zdate, 4) /* 1221 */
month2 = left(month, 2) /* 12 */
event.i.date = month2'/'newz'/'year2
say 'event.i.date =' event.i.date
leave
end
end
end
/* ======== Logging Routine == */
/*
if lg = log then do
if event.i.time = clock2 & event.i.date = date then do
if ~exists('s:cronlog') then do
open(log, 's:cronlog', 'W')
end
else
open(log, 's:cronlog', 'A')
writeln(log, event.i.command "was executed at" event.i.time "on" event.i.date)
close(log)
end
end
*/
/* ======= Final Routine == */
/* if lg = log then delay(25) /* This delay is to allow for the log file
to be deleted automatically if so desired */ */
if event.i.time = clock2 & event.i.date = date then
address command 'run >NIL:' event.i.command event.i.pargs1,
event.i.pargs2 event.i.pargs3 event.i.pargs4
if event.i.time = clock2 & event.i.date = date & event.i.sfx ~= "" then do
if exists('EZCron:prefs/sfx.prefs') then do
open(sfxconfig, 'EZCron:prefs/sfx.prefs', 'r')
sfxplayer = readln(sfxconfig)
close(sfxconfig)
address command 'run >nil:' sfxplayer event.i.sfx
end
end
if event.i.time = clock2 & event.i.date = date & event.i.txt ~= "" then do
address command 'run >nil: rx >nil: ezcron:rexx/Reminder.rexx' event.i.txt /*This calls the external rexx proggy for the event display */
if showlist(h,SPEAK) then do
address command 'echo' event.i.txt '>speak:'
end
end
if event.i.time = clock2 & event.i.date = date
then event.i.date = 'Finished with Event'
end /* end of 'do i = 1 to event.0' */
end /* end of do forever */
/* ======== CLEANUP == */
if event.0 = 0 then exit
options failat 300
trace 'Off'
/* ======== Arexx Port Message Check == */
aport:
Cmd = getarg(Pkt)
if Cmd = 'STOP' then do
call reply(Pkt, rc)
exit
end